﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;

namespace DALL.View
{
   public class V_FistFile
    {
       	/// <summary>
		/// 获得数据列表（比DataSet效率高，推荐使用）
		/// </summary>
		public List<Model.View.V_FistFile> GetListArray(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select FILE_ID,BRANCH_ID,MODULE,FILE_TITEL,URLVideoPhoto,URLOriginal,URLThumbnail ");
			strSql.Append(" FROM V_FistFile ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			List<Model.View.V_FistFile> list = new List<Model.View.V_FistFile>();
			Database db = DatabaseFactory.CreateDatabase();
			using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
			{
				while (dataReader.Read())
				{
					list.Add(ReaderBind(dataReader));
				}
			}
			return list;
		}


		/// <summary>
		/// 对象实体绑定数据
		/// </summary>
		public Model.View.V_FistFile ReaderBind(IDataReader dataReader)
		{
			Model.View.V_FistFile model=new Model.View.V_FistFile();
			object ojb; 
			model.FILE_ID=dataReader["FILE_ID"].ToString();
			ojb = dataReader["BRANCH_ID"];
			if(ojb != null && ojb != DBNull.Value)
			{
				model.BRANCH_ID=(int)ojb;
			}
			model.MODULE=dataReader["MODULE"].ToString();
			model.FILE_TITEL=dataReader["FILE_TITEL"].ToString();
			model.URLVideoPhoto=dataReader["URLVideoPhoto"].ToString();
			model.URLOriginal=dataReader["URLOriginal"].ToString();
			model.URLThumbnail=dataReader["URLThumbnail"].ToString();
			return model;
		}

    }
}
